package com.brainwave.utils;

/**
 * 应用常量定义
 * 包含所有在应用中使用的常量值
 */
public final class Constants {
    
    // 防止实例化
    private Constants() {
        throw new AssertionError("Constants class should not be instantiated");
    }
    
    // ==================== 应用信息 ====================
    public static final String APP_NAME = "BrainWave NeuroSky";
    public static final String APP_VERSION = "1.0.0";
    public static final String PACKAGE_NAME = "com.brainwave.neuroskyapp";
    
    // ==================== 蓝牙相关 ====================
    public static final String NEUROSKY_DEVICE_NAME = "MindWave";
    public static final String NEUROSKY_DEVICE_PREFIX = "MindWave";
    public static final int BLUETOOTH_SCAN_DURATION = 12000; // 12秒
    public static final int BLUETOOTH_CONNECT_TIMEOUT = 10000; // 10秒
    public static final int BLUETOOTH_RECONNECT_DELAY = 3000; // 3秒
    public static final int MAX_RECONNECT_ATTEMPTS = 5;
    
    // NeuroSky 协议常量
    public static final byte SYNC_BYTE = (byte) 0xAA;
    public static final byte EXCODE_BYTE = (byte) 0x55;
    
    // 数据类型代码
    public static final byte CODE_POOR_SIGNAL = (byte) 0x02;
    public static final byte CODE_ATTENTION = (byte) 0x04;
    public static final byte CODE_MEDITATION = (byte) 0x05;
    public static final byte CODE_BLINK_STRENGTH = (byte) 0x16;
    public static final byte CODE_RAW_VALUE = (byte) 0x80;
    public static final byte CODE_EEG_POWER = (byte) 0x83;
    
    // ==================== 数据处理 ====================
    public static final int RAW_DATA_SAMPLE_RATE = 512; // Hz
    public static final int DATA_BUFFER_SIZE = 1024;
    public static final int BATCH_SIZE = 100;
    public static final int DATA_PROCESSING_INTERVAL = 1000; // 1秒
    
    // EEG 频段范围 (Hz)
    public static final float DELTA_MIN = 0.5f;
    public static final float DELTA_MAX = 4.0f;
    public static final float THETA_MIN = 4.0f;
    public static final float THETA_MAX = 8.0f;
    public static final float ALPHA_MIN = 8.0f;
    public static final float ALPHA_MAX = 13.0f;
    public static final float BETA_MIN = 13.0f;
    public static final float BETA_MAX = 30.0f;
    public static final float GAMMA_MIN = 30.0f;
    public static final float GAMMA_MAX = 100.0f;
    
    // ==================== 网络通信 ====================
    public static final String BASE_URL = "https://api.brainwave.com/";
    public static final String API_VERSION = "v1";
    public static final int NETWORK_TIMEOUT = 30000; // 30秒
    public static final int NETWORK_RETRY_COUNT = 3;
    public static final int NETWORK_RETRY_DELAY = 2000; // 2秒
    
    // API 端点
    public static final String ENDPOINT_UPLOAD_DATA = "data/upload";
    public static final String ENDPOINT_GET_ANALYSIS = "analysis/get";
    public static final String ENDPOINT_USER_PROFILE = "user/profile";
    public static final String ENDPOINT_DEVICE_INFO = "device/info";
    
    // ==================== 数据库 ====================
    public static final String DATABASE_NAME = "brainwave_db";
    public static final int DATABASE_VERSION = 1;
    
    // 表名
    public static final String TABLE_RAW_DATA = "raw_data";
    public static final String TABLE_PROCESSED_DATA = "processed_data";
    public static final String TABLE_SESSIONS = "sessions";
    public static final String TABLE_USER_PROFILE = "user_profile";
    
    // ==================== UI 相关 ====================
    public static final int CHART_MAX_VISIBLE_COUNT = 100;
    public static final int CHART_UPDATE_INTERVAL = 100; // 100ms
    public static final float CHART_ANIMATION_DURATION = 500f; // 0.5秒
    
    // 颜色常量 (十六进制)
    public static final int COLOR_DELTA = 0xFF9C27B0;   // 紫色
    public static final int COLOR_THETA = 0xFF2196F3;   // 蓝色
    public static final int COLOR_ALPHA = 0xFF4CAF50;   // 绿色
    public static final int COLOR_BETA = 0xFFFF9800;    // 橙色
    public static final int COLOR_GAMMA = 0xFFF44336;   // 红色
    public static final int COLOR_ATTENTION = 0xFF00BCD4; // 青色
    public static final int COLOR_MEDITATION = 0xFF8BC34A; // 浅绿色
    
    // ==================== 文件存储 ====================
    public static final String EXPORT_FOLDER = "BrainWave";
    public static final String EXPORT_FILE_PREFIX = "brainwave_data_";
    public static final String EXPORT_FILE_EXTENSION = ".csv";
    public static final String LOG_FILE_NAME = "brainwave.log";
    
    // ==================== SharedPreferences ====================
    public static final String PREFS_NAME = "brainwave_prefs";
    public static final String PREF_FIRST_RUN = "first_run";
    public static final String PREF_DEVICE_ADDRESS = "device_address";
    public static final String PREF_AUTO_CONNECT = "auto_connect";
    public static final String PREF_DATA_SYNC_ENABLED = "data_sync_enabled";
    public static final String PREF_NOTIFICATION_ENABLED = "notification_enabled";
    public static final String PREF_CHART_STYLE = "chart_style";
    public static final String PREF_SAMPLE_RATE = "sample_rate";
    
    // ==================== 通知 ====================
    public static final String NOTIFICATION_CHANNEL_ID = "brainwave_channel";
    public static final String NOTIFICATION_CHANNEL_NAME = "BrainWave Service";
    public static final int NOTIFICATION_ID_SERVICE = 1001;
    public static final int NOTIFICATION_ID_DATA_SYNC = 1002;
    public static final int NOTIFICATION_ID_CONNECTION = 1003;
    
    // ==================== Intent Actions ====================
    public static final String ACTION_BLUETOOTH_CONNECTED = "com.brainwave.BLUETOOTH_CONNECTED";
    public static final String ACTION_BLUETOOTH_DISCONNECTED = "com.brainwave.BLUETOOTH_DISCONNECTED";
    public static final String ACTION_DATA_RECEIVED = "com.brainwave.DATA_RECEIVED";
    public static final String ACTION_DATA_PROCESSED = "com.brainwave.DATA_PROCESSED";
    public static final String ACTION_SYNC_COMPLETED = "com.brainwave.SYNC_COMPLETED";
    
    // ==================== Bundle Keys ====================
    public static final String EXTRA_DEVICE_ADDRESS = "device_address";
    public static final String EXTRA_DEVICE_NAME = "device_name";
    public static final String EXTRA_CONNECTION_STATE = "connection_state";
    public static final String EXTRA_DATA_TYPE = "data_type";
    public static final String EXTRA_DATA_VALUE = "data_value";
    public static final String EXTRA_ERROR_MESSAGE = "error_message";
    
    // ==================== 错误代码 ====================
    public static final int ERROR_BLUETOOTH_NOT_SUPPORTED = 1001;
    public static final int ERROR_BLUETOOTH_NOT_ENABLED = 1002;
    public static final int ERROR_DEVICE_NOT_FOUND = 1003;
    public static final int ERROR_CONNECTION_FAILED = 1004;
    public static final int ERROR_DATA_PARSING_FAILED = 1005;
    public static final int ERROR_NETWORK_UNAVAILABLE = 1006;
    public static final int ERROR_SERVER_ERROR = 1007;
    public static final int ERROR_PERMISSION_DENIED = 1008;
    
    // ==================== 时间相关 ====================
    public static final long SESSION_TIMEOUT = 30 * 60 * 1000; // 30分钟
    public static final long DATA_RETENTION_PERIOD = 30 * 24 * 60 * 60 * 1000L; // 30天
    public static final long SYNC_INTERVAL = 5 * 60 * 1000; // 5分钟
    
    // ==================== 数据验证 ====================
    public static final int MIN_SIGNAL_QUALITY = 0;
    public static final int MAX_SIGNAL_QUALITY = 200;
    public static final int MIN_ATTENTION_VALUE = 0;
    public static final int MAX_ATTENTION_VALUE = 100;
    public static final int MIN_MEDITATION_VALUE = 0;
    public static final int MAX_MEDITATION_VALUE = 100;
    public static final int MIN_RAW_VALUE = -32768;
    public static final int MAX_RAW_VALUE = 32767;
}